<template>
    <div class="app-container">
        <el-card class="main-card">
            <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="75px" style="margin-bottom: -20px" v-show="showSearch">
                <el-form-item label="设备名称" prop="deviceDtuGroupName">
                    <el-input v-model="queryParams.deviceDtuGroupName" placeholder="请输入设备名称" clearable size="small" style="width: 150px" />
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" icon="el-icon-search" size="mini" @click="getList()">搜索</el-button>
                    <el-button icon="el-icon-refresh" size="mini" @click="getQueryCz">重置</el-button>
                </el-form-item>
            </el-form>
        </el-card>
        <el-card class="main-card">
            <div class="mb20 mt20">
                <el-button type="primary" icon="el-icon-plus" size="mini" v-hasPermi="['dtu:devicondtu:add']" @click="getFormopen(null)">新增分组</el-button>
            </div>
            <el-table :data="tableData" :border="false" style="width: 100%; margin-top: 10px">
                <el-table-column prop="deviceDtuGroupName" label="分组名称" align="center" width="300px"></el-table-column>
                <el-table-column prop="countDtuDev" label="设备数量" align="center" width="150px"></el-table-column>
                <el-table-column label="创建时间" align="center" width="150px">
                    <template slot-scope="scope">
                        <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="操作" align="center">
                    <template slot-scope="scope">
                        <el-button size="small" type="text" v-hasPermi="['iot:zutai:update']" @click="getCspz(scope.row.deviceDtuJosn, scope.row.deviceDtuGroupid)">参数配置</el-button>
                        <!-- <el-button size="small" type="text" v-hasPermi="['iot:zutai:update']" @click="">设备管理</el-button> -->
                        <el-button size="small" type="text" v-hasPermi="['iot:zutai:update']" @click="deleteDtuDevGroup(scope.row.deviceDtuGroupid)">删除</el-button>
                        <!-- <el-button size="small" type="text" @click="">复制</el-button>
                    <el-button size="small" type="text" @click="">导出配置</el-button> -->
                        <el-button size="small" type="text" @click="getFormopen(scope.row)">修改名称</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" />
        </el-card>
        <!--参数配置-->
        <el-dialog title="参数配置" :visible.sync="Pzopen" width="75%" append-to-body>
            <div style="height: 700px; overflow-y: auto">
                <el-form ref="form" :model="form" style="font-size: 13px">
                    <el-tabs v-model="activeName" @tab-click="handleClick(this.activeName)">
                        <el-tab-pane label="基本参数" name="first">
                            <el-form-item label="模式:">
                                <el-radio-group v-model="form.passon">
                                    <el-radio :label="0">透传</el-radio>
                                    <el-radio :label="1">单片机控制</el-radio>
                                </el-radio-group>
                            </el-form-item>
                            <el-form-item label="是否加设备识别码IMEI:" v-if="form.passon === 0">
                                <el-radio-group v-model="form.plate">
                                    <el-radio :label="0">不加</el-radio>
                                    <el-radio :label="1">加</el-radio>
                                </el-radio-group>
                            </el-form-item>
                            <el-form-item label="报文转换（bin -- hex）:">
                                <el-radio-group v-model="form.convert">
                                    <el-radio :label="1">转换</el-radio>
                                    <el-radio :label="0">不换</el-radio>
                                </el-radio-group>
                                <span style="margin-left: 2%">提示: 如果启用数据流模板，这里选择“不换“</span>
                            </el-form-item>
                            <el-form-item label="首次登陆服务器发送注册信息:">
                                <el-radio-group v-model="form.reg.type">
                                    <el-radio :label="1">发送{csq:rssi,imei:imei,iccid:iccid,ver:Version}</el-radio>
                                    <el-radio :label="2">发送HEX报文"13,12345,12345"</el-radio>
                                    <el-radio :label="0">不发</el-radio>
                                    <el-radio :label="3">自定义</el-radio>
                                    <el-radio :label="4">顺序生成</el-radio>
                                </el-radio-group>
                                <div v-if="form.reg.type === 3" style="margin-top: 10px">
                                    <el-input v-model="form.reg.data" style="width: 200px"></el-input>
                                </div>
                                <div v-if="form.reg.type === 4" style="margin-top: 10px">
                                    <span>前缀：</span>
                                    <el-input v-model="form.reg.prefix" style="width: 200px"></el-input>
                                    <span style="margin-left: 2%">后缀：</span>
                                    <el-input v-model="form.reg.postfix" style="width: 200px"></el-input>
                                </div>
                            </el-form-item>
                            <el-form-item label="参数版本号:">
                                <el-input-number v-model="form.param_ver" controls-position="right" style="width: 200px"></el-input-number>
                                <span style="margin-left: 2%">提示: 范围 1~n</span>
                            </el-form-item>
                            <el-form-item label="每分钟最大串口流量(Byte):">
                                <el-input v-model="form.flow" style="width: 200px"></el-input>
                                <span style="margin-left: 2%">提示: 0为不启用</span>
                            </el-form-item>
                            <el-form-item label="是否启用自动更新:">
                                <el-radio-group v-model="form.fota">
                                    <el-radio :label="0">否</el-radio>
                                    <el-radio :label="1">是</el-radio>
                                </el-radio-group>
                            </el-form-item>
                            <el-form-item label="串口分帧超时:">
                                <el-input-number v-model="form.uartReadTime" controls-position="right" style="width: 200px"></el-input-number>
                                <span style="margin-left: 2%">提示:（单位：ms 默认25ms，范围10-2000）</span>
                            </el-form-item>
                            <el-form-item label="电源模式:">
                                <el-radio-group v-model="form.pwrmod">
                                    <el-radio label="normal">正常</el-radio>
                                    <el-radio label="energy">节能</el-radio>
                                </el-radio-group>
                            </el-form-item>
                            <el-form-item label="配置密码:">
                                <el-input v-model="form.password" style="width: 200px"></el-input>
                                <span style="margin-left: 2%">提示:只允许包含字母数字_</span>
                            </el-form-item>
                            <el-form-item label="网络分帧超时:">
                                <el-input v-model="form.netReadTime" style="width: 200px"></el-input>
                                <span style="margin-left: 2%">提示:同串口分帧超时，默认 0</span>
                            </el-form-item>
                            <el-form-item label="日志输出:">
                                <el-radio-group v-model="form.nolog">
                                    <el-radio label="0">关闭</el-radio>
                                    <el-radio label="1">开启</el-radio>
                                </el-radio-group>
                            </el-form-item>
                            <el-form-item label="是否打开RNDIS:">
                                <el-radio-group v-model="form.isRndis">
                                    <el-radio label="0">关闭</el-radio>
                                    <el-radio label="1">开启</el-radio>
                                </el-radio-group>
                            </el-form-item>
                            <el-form-item label="是否打开ipv6:">
                                <el-radio-group v-model="form.isipv6">
                                    <el-radio label="0">关闭</el-radio>
                                    <el-radio label="1">开启</el-radio>
                                </el-radio-group>
                                <span style="margin-left: 2%">提示:目前仅780E/700E/600E/780EX/780EG支持该选项，724/720系列/820/600ug等模组不支持</span>
                            </el-form-item>
                            <el-form-item label="是否守护全部网络通道:">
                                <el-radio-group v-model="form.webProtect">
                                    <el-radio label="0">个别</el-radio>
                                    <el-radio label="1">全部</el-radio>
                                </el-radio-group>
                            </el-form-item>
                            <p>提示: 服务器连接断开时5分钟会重启，守护全部通道有一个断开就重启，守护个别通道在个别通道断开会重启</p>
                            <el-form-item label="守护的线路:" v-if="form.webProtect === '0'">
                                <el-checkbox-group v-model="form.protectContent">
                                    <el-checkbox v-for="channel in channels" :key="channel.id" :label="channel.id">
                                        {{ channel.name }}
                                    </el-checkbox>
                                </el-checkbox-group>
                            </el-form-item>
                        </el-tab-pane>
                        <el-tab-pane label="串口参数" name="second">
                            <el-tabs v-model="activeNameckcs" @tab-click="handleClick01">
                                <el-tab-pane label="串口1" name="ckcs01">
                                    <el-form-item>
                                        <el-radio-group v-model="uconfData[0].ckcs01">
                                            <el-radio label="1">启动</el-radio>
                                            <el-radio label="0">不启动</el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                    <div v-if="uconfData[0].ckcs01 == 1">
                                        <el-form-item label="波特率:">
                                            <el-select v-model="uconfData[0].btl01" clearable placeholder="请选择">
                                                <el-option v-for="item in optionsbtl" :key="item.value" :label="item.label" :value="item.value"></el-option>
                                            </el-select>
                                            <span style="margin-left: 2%">单位bps</span>
                                        </el-form-item>
                                        <el-form-item label="数据位:">
                                            <el-radio-group v-model="uconfData[0].sjw01">
                                                <el-radio label="8">8</el-radio>
                                                <el-radio label="7">7</el-radio>
                                            </el-radio-group>
                                        </el-form-item>
                                        <el-form-item label="校验位:">
                                            <el-radio-group v-model="uconfData[0].xyw01">
                                                <el-radio label="0">uart.PAR_EVEN</el-radio>
                                                <el-radio label="1">uart.PAR_ODD</el-radio>
                                                <el-radio label="2">uart.PAR_NONE</el-radio>
                                            </el-radio-group>
                                        </el-form-item>
                                        <el-form-item label="停止位:">
                                            <el-radio-group v-model="uconfData[0].tzw01">
                                                <el-radio label="1">1</el-radio>
                                                <el-radio label="2">2</el-radio>
                                            </el-radio-group>
                                        </el-form-item>
                                        <el-form-item label="485DIR:">
                                            <el-select v-model="uconfData[0].dir01" clearable placeholder="请选择">
                                                <el-option v-for="item in optionsDir" :key="item.value" :label="item.label" :value="item.value"></el-option>
                                            </el-select>
                                            <span style="margin-left: 2%">提示: 485方向控制GPIO</span>
                                        </el-form-item>
                                        <el-form-item label="485oe转向延迟时间:">
                                            <el-input v-model="uconfData[0].zxycsj01" style="width: 200px"></el-input>
                                            <span style="margin-left: 2%">单位US</span>
                                        </el-form-item>
                                    </div>
                                </el-tab-pane>
                                <el-tab-pane label="串口2" name="ckcs02">
                                    <el-form-item>
                                        <el-radio-group v-model="uconfData[1].ckcs01">
                                            <el-radio label="1">启动</el-radio>
                                            <el-radio label="0">不启动</el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                    <div v-if="uconfData[1].ckcs01 == 1">
                                        <el-form-item label="波特率:">
                                            <el-select v-model="uconfData[1].btl01" clearable placeholder="请选择">
                                                <el-option v-for="item in optionsbtl" :key="item.value" :label="item.label" :value="item.value"></el-option>
                                            </el-select>
                                            <span style="margin-left: 2%">单位bps</span>
                                        </el-form-item>
                                        <el-form-item label="数据位:">
                                            <el-radio-group v-model="uconfData[1].sjw01">
                                                <el-radio label="8">8</el-radio>
                                                <el-radio label="7">7</el-radio>
                                            </el-radio-group>
                                        </el-form-item>
                                        <el-form-item label="校验位:">
                                            <el-radio-group v-model="uconfData[1].xyw01">
                                                <el-radio label="0">uart.PAR_EVEN</el-radio>
                                                <el-radio label="1">uart.PAR_ODD</el-radio>
                                                <el-radio label="2">uart.PAR_NONE</el-radio>
                                            </el-radio-group>
                                        </el-form-item>
                                        <el-form-item label="停止位:">
                                            <el-radio-group v-model="uconfData[1].tzw01">
                                                <el-radio label="1">1</el-radio>
                                                <el-radio label="2">2</el-radio>
                                            </el-radio-group>
                                        </el-form-item>
                                        <el-form-item label="485DIR:">
                                            <el-select v-model="uconfData[1].dir01" clearable placeholder="请选择">
                                                <el-option v-for="item in optionsDir" :key="item.value" :label="item.label" :value="item.value"></el-option>
                                            </el-select>
                                            <span style="margin-left: 2%">提示: 485方向控制GPIO</span>
                                        </el-form-item>
                                        <el-form-item label="485oe转向延迟时间:">
                                            <el-input v-model="uconfData[1].zxycsj01" style="width: 200px"></el-input>
                                            <span style="margin-left: 2%">单位US</span>
                                        </el-form-item>
                                    </div>
                                </el-tab-pane>
                                <el-tab-pane label="串口3" name="ckcs03">
                                    <el-form-item>
                                        <el-radio-group v-model="uconfData[2].ckcs01">
                                            <el-radio label="1">启动</el-radio>
                                            <el-radio label="0">不启动</el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                    <div v-if="uconfData[2].ckcs01 == 1">
                                        <el-form-item label="波特率:">
                                            <el-select v-model="uconfData[2].btl01" clearable placeholder="请选择">
                                                <el-option v-for="item in optionsbtl" :key="item.value" :label="item.label" :value="item.value"></el-option>
                                            </el-select>
                                            <span style="margin-left: 2%">单位bps</span>
                                        </el-form-item>
                                        <el-form-item label="数据位:">
                                            <el-radio-group v-model="uconfData[2].sjw01">
                                                <el-radio label="8">8</el-radio>
                                                <el-radio label="7">7</el-radio>
                                            </el-radio-group>
                                        </el-form-item>
                                        <el-form-item label="校验位:">
                                            <el-radio-group v-model="uconfData[2].xyw01">
                                                <el-radio label="0">uart.PAR_EVEN</el-radio>
                                                <el-radio label="1">uart.PAR_ODD</el-radio>
                                                <el-radio label="2">uart.PAR_NONE</el-radio>
                                            </el-radio-group>
                                        </el-form-item>
                                        <el-form-item label="停止位:">
                                            <el-radio-group v-model="uconfData[2].tzw01">
                                                <el-radio label="1">1</el-radio>
                                                <el-radio label="2">2</el-radio>
                                            </el-radio-group>
                                        </el-form-item>
                                        <el-form-item label="485DIR:">
                                            <el-select v-model="uconfData[2].dir01" clearable placeholder="请选择">
                                                <el-option v-for="item in optionsDir" :key="item.value" :label="item.label" :value="item.value"></el-option>
                                            </el-select>
                                            <span style="margin-left: 2%">提示: 485方向控制GPIO</span>
                                        </el-form-item>
                                        <el-form-item label="485oe转向延迟时间:">
                                            <el-input v-model="uconfData[2].zxycsj01" style="width: 200px"></el-input>
                                            <span style="margin-left: 2%">单位US</span>
                                        </el-form-item>
                                    </div>
                                </el-tab-pane>
                            </el-tabs>
                        </el-tab-pane>
                        <el-tab-pane label="网络通道参数" name="third">
                            <el-tabs v-model="activeNameTdcs" @tab-click="handleClick01">
                                <el-tab-pane label="通道一" name="tdcs01">
                                    <el-form-item>
                                        <el-radio-group v-model="form.tdcs01">
                                            <el-radio label="0">启动</el-radio>
                                            <el-radio label="1">不启动</el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                    <div v-if="form.tdcs01 == 0">
                                        <el-form-item label="通道类型:">
                                            <el-radio-group v-model="form.tdlx01">
                                                <el-radio label="HTTP">HTTP</el-radio>
                                                <el-radio label="SOCKET">SOCKET</el-radio>
                                                <el-radio label="MQTT">MQTT</el-radio>
                                                <el-radio label="OneNET">OneNET</el-radio>
                                                <el-radio label="阿里云">阿里云</el-radio>
                                                <el-radio label="百度云">百度云</el-radio>
                                                <el-radio label="腾讯云">腾讯云</el-radio>
                                                <el-radio label="腾讯云（new）">腾讯云（new）</el-radio>
                                                <el-radio label="onenet（new）">onenet（new）</el-radio>
                                                <el-radio label="LuatCloud">LuatCloud</el-radio>
                                            </el-radio-group>
                                        </el-form-item>
                                        <div v-if="form.tdlx01 == 'HTTP'">
                                            <el-form-item label="HTTP绑定串口ID:">
                                                <el-radio-group v-model="confData[0].port">
                                                    <el-radio label="1">1</el-radio>
                                                    <el-radio label="2">2</el-radio>
                                                </el-radio-group>
                                            </el-form-item>
                                            <el-form-item label="method:">
                                                <el-radio-group v-model="confData[0].method">
                                                    <el-radio label="get">get</el-radio>
                                                    <el-radio label="post">post</el-radio>
                                                </el-radio-group>
                                                <span style="margin-left: 2%">提示：提交请求的方法</span>
                                            </el-form-item>
                                            <el-form-item label="url:">
                                                <el-input v-model="confData[0].url" style="width: 200px"></el-input>
                                                <span style="margin-left: 2%">提示： HTTP请求的地址和参数，参数需要自己urllencode处理</span>
                                            </el-form-item>
                                            <el-form-item label="timeout:">
                                                <el-input v-model="confData[0].timeout" style="width: 200px"></el-input>
                                                <span style="margin-left: 2%">提示： HTTP请求最长等待时间，超过这个时间，HTTP将返回</span>
                                            </el-form-item>
                                            <el-form-item label="请求类型:">
                                                <el-radio-group v-model="confData[0].request">
                                                    <el-radio label="body">body</el-radio>
                                                    <el-radio label="param">param</el-radio>
                                                </el-radio-group>
                                                <span style="margin-left: 2%">提示： 串口数据类型，默认body</span>
                                            </el-form-item>
                                            <el-form-item label="type:">
                                                <el-radio-group v-model="confData[0].type">
                                                    <el-radio label="urlencode">urlencode</el-radio>
                                                    <el-radio label="json">json</el-radio>
                                                    <el-radio label="stream">stream</el-radio>
                                                </el-radio-group>
                                                <span style="margin-left: 2%">提示： body的提交类型</span>
                                            </el-form-item>
                                            <el-form-item label="basic:">
                                                <el-input v-model="confData[0].basic" style="width: 200px"></el-input>
                                                <span style="margin-left: 2%">提示：HTTP的BASIC验证，注意账号密码之间用 ： 连接</span>
                                            </el-form-item>
                                            <el-form-item label="head:">
                                                <el-input v-model="confData[0].header" style="width: 200px"></el-input>
                                                <span style="margin-left: 2%">提示：HTTP请求报文头部字符串</span>
                                            </el-form-item>
                                            <el-form-item label="返回数据过滤:">
                                                <el-radio-group v-model="confData[0].filter">
                                                    <el-radio label="code">code</el-radio>
                                                    <el-radio label="head">head</el-radio>
                                                    <el-radio label="body">body</el-radio>
                                                </el-radio-group>
                                            </el-form-item>
                                        </div>
                                        <div v-if="form.tdlx01 == 'SOCKET'">
                                            <el-form-item label="协议:">
                                                <el-radio-group v-model="confData[1].agree">
                                                    <el-radio label="tcp">TCP协议</el-radio>
                                                    <el-radio label="udp">UDP协议</el-radio>
                                                </el-radio-group>
                                            </el-form-item>
                                            <el-form-item label="心跳包:">
                                                <el-radio-group v-model="confData[1].heartData.type">
                                                    <el-radio label="0">自定义</el-radio>
                                                    <el-radio label="1">顺序生成</el-radio>
                                                </el-radio-group>
                                                <div v-if="confData[1].heartData.type == '0'" style="margin-top: 10px">
                                                    <el-input v-model="confData[1].heartData.data" style="width: 200px"></el-input>
                                                </div>
                                                <div v-if="confData[1].heartData.type == '1'" style="margin-top: 10px">
                                                    <span>前缀：</span>
                                                    <el-input v-model="confData[1].heartData.prefix" style="width: 200px"></el-input>
                                                    <span style="margin-left: 2%">后缀：</span>
                                                    <el-input v-model="confData[1].heartData.postfix" style="width: 200px"></el-input>
                                                </div>
                                            </el-form-item>
                                            <el-form-item label="心跳间隔时间:">
                                                <el-input v-model="confData[1].heartInterval" style="width: 200px"></el-input>
                                                <span style="margin-left: 2%">(单位秒) 提示： 0为关闭心跳包，建议60-300</span>
                                            </el-form-item>
                                            <el-form-item label="socket的地址或域名:">
                                                <el-input v-model="confData[1].url" style="width: 200px"></el-input>
                                            </el-form-item>
                                            <el-form-item label="socket服务器的端口号:">
                                                <el-input-number controls-position="right" v-model="confData[1].port" style="width: 200px"></el-input-number>
                                                <span style="margin-left: 2%">提示: 端口号范围：1~65536</span>
                                            </el-form-item>
                                            <el-form-item label="TCP通道捆绑的串口ID :">
                                                <el-radio-group v-model="confData[1].serial">
                                                    <el-radio label="1">1</el-radio>
                                                    <el-radio label="2">2</el-radio>
                                                    <el-radio label="3">3</el-radio>
                                                </el-radio-group>
                                            </el-form-item>
                                            <el-form-item label="被动上报间隔 :">
                                                <el-input v-model="confData[1].report" style="width: 200px"></el-input>
                                                <span style="margin-left: 2%">(单位秒) 提示: 非被动模式留空 范围：1~65535</span>
                                            </el-form-item>
                                            <el-form-item label="被动采集间隔 :">
                                                <el-input v-model="confData[1].collect" style="width: 200px"></el-input>
                                                <span style="margin-left: 2%">(单位秒) 提示: 非被动模式留空 范围：1~15</span>
                                            </el-form-item>
                                            <el-form-item label="自动采集任务间隔时间 :">
                                                <el-input-number controls-position="right" v-model="confData[1].collect2" style="width: 200px"></el-input-number>
                                                <span style="margin-left: 2%">(单位秒) 提示:主动采集任务间隔时间,配合自动采集任务使用</span>
                                            </el-form-item>
                                            <el-form-item label="SSL :" v-if="confData[1].agree == 'tcp'">
                                                <el-radio-group v-model="confData[1].ssl">
                                                    <el-radio label="ssl">启用</el-radio>
                                                    <el-radio label="">不启用</el-radio>
                                                </el-radio-group>
                                            </el-form-item>
                                        </div>
                                        <div v-if="form.tdlx01 == 'MQTT'">
                                            <el-form-item label="MQTT心跳包的间隔:">
                                                <el-input v-model="confData[2].heartInterval" style="width: 200px"></el-input>
                                                <span style="margin-left: 2%">提示： 单位秒,默认300</span>
                                            </el-form-item>
                                            <el-form-item label="自动采集任务间隔时间:">
                                                <el-input v-model="confData[2].collect2" style="width: 200px"></el-input>
                                                <span style="margin-left: 2%">提示： MQTT接收超时时间,单位秒,配合自动采集任务使用</span>
                                            </el-form-item>
                                            <el-form-item label="MQTT的地址或域名:">
                                                <el-input v-model="confData[2].url" style="width: 200px"></el-input>
                                            </el-form-item>
                                            <el-form-item label="MQTT服务器的端口号:">
                                                <el-input v-model="confData[2].port" style="width: 200px"></el-input>
                                                <span style="margin-left: 2%">提示: 端口号范围：1~65536</span>
                                            </el-form-item>
                                            <el-form-item label="MQTT的登陆账号:">
                                                <el-input v-model="confData[2].serverId" style="width: 200px"></el-input>
                                            </el-form-item>
                                            <el-form-item label="MQTT的登陆密码:">
                                                <el-input v-model="confData[2].password" style="width: 200px"></el-input>
                                            </el-form-item>
                                            <el-form-item label="MQTT保存会话标志位:">
                                                <el-radio-group v-model="confData[2].session">
                                                    <el-radio label="0">持久会话</el-radio>
                                                    <el-radio label="1">离线自动销毁</el-radio>
                                                </el-radio-group>
                                            </el-form-item>
                                            <el-form-item label="订阅消息主题:">
                                                <el-input v-model="confData[2].subscribe" style="width: 200px"></el-input>
                                            </el-form-item>
                                            <el-form-item label="发布消息主题:">
                                                <el-input v-model="confData[2].release" style="width: 200px"></el-input>
                                            </el-form-item>
                                            <el-form-item label="MQTT的QOS级别:">
                                                <el-radio-group v-model="confData[2].qos">
                                                    <el-radio label="0">0</el-radio>
                                                    <el-radio label="1">1</el-radio>
                                                    <el-radio label="2">2</el-radio>
                                                </el-radio-group>
                                            </el-form-item>
                                            <el-form-item label="MQTT的publish参数retain:">
                                                <el-radio-group v-model="confData[2].retain">
                                                    <el-radio label="0">0</el-radio>
                                                    <el-radio label="1">1</el-radio>
                                                </el-radio-group>
                                            </el-form-item>
                                            <el-form-item label="MQTT通道捆绑的串口ID:">
                                                <el-radio-group v-model="confData[2].serial">
                                                    <el-radio label="1">1</el-radio>
                                                    <el-radio label="2">2</el-radio>
                                                    <el-radio label="3">3</el-radio>
                                                </el-radio-group>
                                            </el-form-item>
                                            <el-form-item label="ID是否添加默认IMEI :">
                                                <el-radio-group v-model="confData[2].IMEI">
                                                    <el-radio label="">是</el-radio>
                                                    <el-radio label="1">否</el-radio>
                                                </el-radio-group>
                                                <span style="margin-left: 2%">提示： （默认添加IMEI，选是的格式是IMEI+内容，选否则自定义内容，不填则默认IMEI）</span>
                                            </el-form-item>
                                            <el-form-item label="接收mqtt信息是否显示主题 :">
                                                <el-radio-group v-model="confData[2].show">
                                                    <el-radio label="1">是</el-radio>
                                                    <el-radio label="">否</el-radio>
                                                </el-radio-group>
                                                <span style="margin-left: 2%">提示： （默认不显示主题,显示格式为[+MSUB: topic,len,message]）</span>
                                            </el-form-item>
                                            <el-form-item label="客户端ID:">
                                                <el-input v-model="confData[2].userId" style="width: 200px"></el-input>
                                                <span style="margin-left: 2%">提示： 不填系统用IMEI做客户端ID</span>
                                            </el-form-item>
                                            <el-form-item label="主题添加IMEI :">
                                                <el-radio-group v-model="confData[2].addIMEI">
                                                    <el-radio label="">是</el-radio>
                                                    <el-radio label="1">否</el-radio>
                                                </el-radio-group>
                                                <span style="margin-left: 2%">提示： 默认添加（/自定义主题/IMEI）</span>
                                            </el-form-item>
                                            <el-form-item label="transport:">
                                                <el-radio-group v-model="confData[2].transport">
                                                    <el-radio label="tcp">tcp</el-radio>
                                                    <el-radio label="tcp_ssl">tcp_ssl</el-radio>
                                                </el-radio-group>
                                            </el-form-item>
                                            <el-form-item label="MQTT的遗嘱:">
                                                <el-input v-model="confData[2].msg" style="width: 200px"></el-input>
                                                <span style="margin-left: 2%">提示： 可不填</span>
                                            </el-form-item>
                                        </div>
                                    </div>
                                </el-tab-pane>
                                <el-tab-pane label="通道二" name="tdcs02">
                                    <el-form-item>
                                        <el-radio-group v-model="form.tdcs02">
                                            <el-radio label="0">启动</el-radio>
                                            <el-radio label="1">不启动</el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                </el-tab-pane>
                                <el-tab-pane label="通道三" name="tdcs03">
                                    <el-form-item>
                                        <el-radio-group v-model="form.tdcs03">
                                            <el-radio label="0">启动</el-radio>
                                            <el-radio label="1">不启动</el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                </el-tab-pane>
                                <el-tab-pane label="通道四" name="tdcs04">
                                    <el-form-item>
                                        <el-radio-group v-model="form.tdcs04">
                                            <el-radio label="0">启动</el-radio>
                                            <el-radio label="1">不启动</el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                </el-tab-pane>
                                <el-tab-pane label="通道五" name="tdcs05">
                                    <el-form-item>
                                        <el-radio-group v-model="form.tdcs05">
                                            <el-radio label="0">启动</el-radio>
                                            <el-radio label="1">不启动</el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                </el-tab-pane>
                                <el-tab-pane label="通道六" name="tdcs06">
                                    <el-form-item>
                                        <el-radio-group v-model="form.tdcs06">
                                            <el-radio label="0">启动</el-radio>
                                            <el-radio label="1">不启动</el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                </el-tab-pane>
                                <el-tab-pane label="通道七" name="tdcs07">
                                    <el-form-item>
                                        <el-radio-group v-model="form.tdcs07">
                                            <el-radio label="0">启动</el-radio>
                                            <el-radio label="1">不启动</el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                </el-tab-pane>
                            </el-tabs>
                        </el-tab-pane>
                        <el-tab-pane label="采集信息" name="fifth">
                            <el-form-item>
                                <el-radio-group v-model="gatherStatus">
                                    <el-radio label="1">启动</el-radio>
                                    <el-radio label="0">不启动</el-radio>
                                </el-radio-group>
                            </el-form-item>
                            <div v-if="gatherStatus == '1'">
                                <el-form-item label="485通道:">
                                    <el-input-number v-model="gatherParams['485pass']" controls-position="right" style="width: 200px" :min="1"></el-input-number>
                                </el-form-item>
                                <el-form-item label="网络通道:">
                                    <el-input-number v-model="gatherParams['httpPass']" controls-position="right" style="width: 200px" :min="1"></el-input-number>
                                </el-form-item>
                                <el-form-item label="采集时间 :">
                                    <el-input-number v-model="gatherParams['time']" controls-position="right" style="width: 200px" :min="1"></el-input-number>
                                    <span style="margin-left: 2%">单位 S</span>
                                </el-form-item>
                                <el-form-item label="设备列表 :"></el-form-item>
                                <div style="width: 50%">
                                    <el-card class="main-card" style="margin-bottom: 20px" v-for="(item, index) in gatherParams.devices" :key="index">
                                        <el-form-item label="设备地址:">
                                            <el-input-number v-model="item.address" controls-position="right" style="width: 200px" :min="1" :max="255"></el-input-number>
                                            <span style="margin: 0 30% 0 2%">1 ~ 255</span>
                                            <el-button type="danger" icon="el-icon-delete" size="mini" @click="deviceDelete(index)">删除</el-button>
                                        </el-form-item>
                                        <el-divider></el-divider>
                                        <el-form-item label="">
                                            <el-button
                                                type="primary"
                                                icon="el-icon-plus"
                                                size="mini"
                                                @click="
                                                    deviceIndex = index;
                                                    registerStatus = true;
                                                "
                                            >
                                                寄存器
                                            </el-button>
                                        </el-form-item>
                                        <el-table class="base-table" :border="false" v-loading="loading" :data="item.registers">
                                            <el-table-column label="寄存器地址" align="left" header-align="left" prop="id" min-width="120" />
                                            <el-table-column label="数据类型" align="left" header-align="left" prop="format" min-width="120" />
                                            <el-table-column label="物理标识符" align="left" header-align="left" prop="name" min-width="120" />
                                            <el-table-column label="采集数量 " align="left" header-align="left" prop="number" min-width="120" />
                                            <el-table-column label="操作" align="left" header-align="left" prop="desc" min-width="120">
                                                <template slot-scope="scope">
                                                    <el-button size="small" type="danger" plain style="padding: 5px" icon="el-icon-delete" @click="registerDelete(scope, index)">删除</el-button>
                                                </template>
                                            </el-table-column>
                                        </el-table>
                                    </el-card>
                                </div>
                                <el-button icon="el-icon-plus" @click="addDevice">添加设备</el-button>
                            </div>
                        </el-tab-pane>
                        <el-tab-pane label="预置信息" name="fourth">
                            <h3 style="font-weight: bold">远程更新参数和固件</h3>
                            <el-form-item>
                                <span>白名单号：</span>
                                <el-input v-model="form.bmdh" style="width: 200px"></el-input>
                            </el-form-item>
                            <el-form-item>
                                <span>振铃延时：</span>
                                <el-input v-model="form.zlys" style="width: 200px"></el-input>
                            </el-form-item>
                            <el-form-item>
                                <span>短信字段：</span>
                                <el-input v-model="form.dxzd" style="width: 200px"></el-input>
                            </el-form-item>
                            <h3 style="font-weight: bold">设置APN</h3>
                            <el-form-item>
                                <span>名称：</span>
                                <el-input v-model="form.apnMc" style="width: 200px"></el-input>
                            </el-form-item>
                            <el-form-item>
                                <span>用户名：</span>
                                <el-input v-model="form.apnYhm" style="width: 200px"></el-input>
                            </el-form-item>
                            <el-form-item>
                                <span>密码：</span>
                                <el-input v-model="form.apnMm" style="width: 200px"></el-input>
                            </el-form-item>
                            <h3 style="font-weight: bold">自动采集任务</h3>
                            <el-tabs v-model="activeNameckcsZdcj" @tab-click="handleClick01">
                                <el-tab-pane label="串口1" name="ckcszdcj01">
                                    <el-form-item>
                                        <el-radio-group v-model="form.ckcszdcj01">
                                            <el-radio label="0">启动</el-radio>
                                            <el-radio label="1">不启动</el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                </el-tab-pane>
                                <el-tab-pane label="串口2" name="ckcszdcj02">
                                    <el-form-item>
                                        <el-radio-group v-model="form.ckcszdcj02">
                                            <el-radio label="0">启动</el-radio>
                                            <el-radio label="1">不启动</el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                </el-tab-pane>
                                <el-tab-pane label="串口3" name="ckcszdcj03">
                                    <el-form-item>
                                        <el-radio-group v-model="form.ckcszdcj03">
                                            <el-radio label="0">启动</el-radio>
                                            <el-radio label="1">不启动</el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                </el-tab-pane>
                            </el-tabs>
                        </el-tab-pane>
                        <!--                        <el-tab-pane label="GPIO" name="gpio">GPIO</el-tab-pane>
                        <el-tab-pane label="GPS" name="gps">GPS</el-tab-pane>
                        <el-tab-pane label="视频流" name="spl">视频流</el-tab-pane>
                        <el-tab-pane label="预警" name="yj">预警</el-tab-pane>-->
                        <el-tab-pane label="任务" name="rw">
                            <el-form-item>
                                <el-radio-group v-model="rwsfqy">
                                    <el-radio :label="0">启动</el-radio>
                                    <el-radio :label="1">不启动</el-radio>
                                </el-radio-group>
                            </el-form-item>
                            <div v-if="rwsfqy === 0">
                                <div v-for="task in tasks" class="yh_div">
                                    <ul>
                                        <li>
                                            <h3 style="color: #333; font-size: 19px; font-weight: 500">{{ task.name }}</h3>
                                        </li>
                                        <li class="btn_sc">
                                            <el-button type="info" icon="el-icon-delete" circle @click="removeTask(task.id)"></el-button>
                                        </li>
                                    </ul>
                                    <el-form-item>
                                        <el-input
                                            type="textarea"
                                            :rows="6"
                                            placeholder="function
    wwhile true do
        log.info('----------------doGP025 :1----------------')
        gpio.setup(25.0)
        sys.wait(500)
        log,info('--------------doGp|025 :0---------------_')
        gpio.setup(25, 1)
        sys.wait(150000)
    end
end"
                                            style="max-width: 600px"
                                            v-model="sfdata[task.id - 1]"
                                        ></el-input>
                                    </el-form-item>
                                </div>
                                <el-button icon="el-icon-plus" @click="addTask">用户添加</el-button>
                                <p>提示：用户任务最多10个</p>
                            </div>
                        </el-tab-pane>
                    </el-tabs>
                    <el-divider></el-divider>
                    <el-form-item style="margin-left: 85%">
                        <div style="width: 200px">
                            <el-button type="primary" @click="getform">确定</el-button>
                            <el-button @click="cancel">取消</el-button>
                        </div>
                    </el-form-item>
                </el-form>
            </div>
        </el-dialog>

        <!--添加和修改-->
        <el-dialog :title="title" :visible.sync="Formopen" width="20%" append-to-body>
            <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
                <el-form-item label="设备组名称" prop="deviceDtuGroupName">
                    <el-input v-model="ruleForm.deviceDtuGroupName"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="submitForm('ruleForm')">确定</el-button>
                    <el-button @click="resetForm('ruleForm')">重置</el-button>
                </el-form-item>
            </el-form>
        </el-dialog>
        <el-dialog title="添加寄存器" :visible.sync="registerStatus" width="20%" append-to-body>
            <el-form :model="registerForm" :rules="registerRules" ref="registerform" label-width="100px" class="demo-ruleForm">
                <el-form-item label="寄存器地址" prop="id">
                    <el-input-number v-model="registerForm.id" controls-position="right" style="width: 200px" :min="1"></el-input-number>
                </el-form-item>
                <el-form-item label="数据类型" prop="format">
                    <el-select v-model="registerForm.format" clearable placeholder="请选择">
                        <el-option v-for="item in formatList" :key="item.value" :label="item.label" :value="item.value"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="物理标识符" prop="name">
                    <el-input v-model="registerForm.name"></el-input>
                </el-form-item>
                <el-form-item label="采集数量" prop="num">
                    <el-input-number v-model="registerForm.number" controls-position="right" style="width: 200px" :min="1"></el-input-number>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="addRegister()">确定</el-button>
                    <el-button @click="resetForm('registerform')">重置</el-button>
                </el-form-item>
            </el-form>
        </el-dialog>
    </div>
</template>

<script>
import { getDevDtu, getDtuDeviceGroupList, addAndUpdateDtuDevGroup, deleteDtuDeviceGroup } from '../../../api/iot/device';

export default {
    name: 'Devicedtugroup',
    data() {
        return {
            //查询参数
            queryParams: {
                deviceDtuGroupName: null,
                pageNum: 1,
                pageSize: 10,
            },
            showSearch: true,
            tableData: [],
            total: 0,
            multipleSelection: [],
            Pzopen: false,
            groupid: 0,
            tasks: [],
            rwsfqy: 1,
            uconfData: [
                {
                    ckcs01: 0,
                    btl01: null,
                    sjw01: null,
                    xyw01: null,
                    tzw01: null,
                    dir01: null,
                    zxycsj01: null,
                },
                {
                    ckcs01: 0,
                    btl01: null,
                    sjw01: null,
                    xyw01: null,
                    tzw01: null,
                    dir01: null,
                    zxycsj01: null,
                },
                {
                    ckcs01: 0,
                    btl01: null,
                    sjw01: null,
                    xyw01: null,
                    tzw01: null,
                    dir01: null,
                    zxycsj01: null,
                },
                {
                    ckcs01: 0,
                    btl01: null,
                    sjw01: null,
                    xyw01: null,
                    tzw01: null,
                    dir01: null,
                    zxycsj01: null,
                },
            ],
            confData: [
                {
                    //网口参数 http请求
                    port: 0,
                    method: null,
                    url: null,
                    timeout: null,
                    type: null,
                    request: null,
                    basic: null,
                    header: null,
                    filter: null,
                },
                {
                    //网口参数 http请求
                    aa: 'socket',
                    agree: 'tcp',
                    heartData: {
                        type: '0',
                        data: '0x00',
                        prefix: '',
                        postfix: '',
                    },
                    heartInterval: 300,
                    url: '',
                    port: 2345,
                    serial: '1',
                    report: '',
                    collect: '',
                    collect2: '',
                    ssl: '',
                },
                {
                    agree: 'mqtt',
                    heartInterval: 300,
                    collect2: '1800',
                    url: '',
                    port: 1883,
                    serverId: '',
                    password: '',
                    session: '1',
                    subscribe: '',
                    release: '',
                    qos: '0',
                    retain: '0',
                    serial: '1',
                    userId: '',
                    addIMEI: '',
                    transport: 'tcp',
                    msg: '',
                    IMEI: '',
                    show: '',
                },
            ],
            registerForm: {
                id: '',
                format: '',
                name: '',
                number: '1',
            },
            formatList: [
                {
                    value: 'int16',
                    label: '有符号16位',
                },
                {
                    value: 'uint16',
                    label: '无符号16位',
                },
                {
                    value: 'int32_ABCD',
                    label: '32位 有符号(ABCD)',
                },
                {
                    value: 'int32_CDAB',
                    label: '32位 有符号(CDAB)',
                },
                {
                    value: 'uint32_ABCD',
                    label: '32位 无符号(ABCD)',
                },
                {
                    value: 'uint32_CDAB',
                    label: '32位 无符号(CDAB)',
                },
                {
                    value: 'f32_ABCD',
                    label: '32位浮点数 (ABCD)',
                },
                {
                    value: 'f32_CDAB',
                    label: '32位浮点数 (CDAB)',
                },
            ],
            registerStatus: false,
            deviceIndex: 0,
            gatherStatus: '1',
            gatherParams: {
                '485pass': '',
                httpPass: '',
                time: '',
                devices: [],
            },
            form: {
                fota: 0,
                uartReadTime: 25,
                flow: '',
                param_ver: 1,
                pwrmod: 'normal',
                password: '',
                netReadTime: 0,
                passon: 1,
                nolog: '1',
                isRndis: '0',
                isipv6: '0',
                webProtect: '1',
                plate: 0,
                protectContent: [0, 0, 0, 0, 0, 0, 0],
                reg: {
                    type: 0,
                    data: '',
                    prefix: '',
                    postfix: '',
                },
                convert: 0,
                uconf: [],
                tdlx01: 'SOCKET',
                tdcs01: '1',
                conf: [[], [], [], [], [], [], []],
                auto485: [
                    [
                        '',
                        '',
                        '10',
                        {
                            devices: [
                                {
                                    address: 1,
                                    registers: [
                                        { id: 10, format: 'int16', name: 'A1', number: 5 },
                                        { id: 2, format: 'int16', name: 'A2', number: 5 },
                                    ],
                                },
                                {
                                    address: 1,
                                    registers: [
                                        { id: 4, format: 'int16', name: 'A3', number: 5 },
                                        { id: 7, format: 'int16', name: 'A4', number: 5 },
                                    ],
                                },
                                {
                                    address: 1,
                                    registers: [
                                        { id: 6, format: 'int16', name: 'A5', number: 5 },
                                        { id: 5, format: 'int16', name: 'A6', number: 5 },
                                    ],
                                },
                            ],
                        },
                    ],
                    [],
                    [],
                    [],
                    [],
                    [],
                    [],
                ],
                preset: {
                    number: '',
                    delay: '',
                    smsword: '',
                },
                apn: ['', '', ''],
                cmds: [[], [], []],
                pins: [],
                gps: {
                    pio: [],
                    fun: [],
                },
                upprot: ['', '', '', '', '', '', ''],
                dwprot: ['', '', '', '', '', '', ''],
                warn: {
                    adc0: [],
                    adc1: [],
                    vbatt: [],
                    gpio: [],
                },
            },
            activeName: 'first',
            channels: [
                { id: 1, name: '通道一' },
                { id: 2, name: '通道二' },
                { id: 3, name: '通道三' },
                { id: 4, name: '通道四' },
                { id: 5, name: '通道五' },
                { id: 6, name: '通道六' },
                { id: 7, name: '通道七' },
            ],
            sfdata: [],
            title: null,
            ruleForm: {
                deviceDtuGroupid: null,
                deviceDtuGroupName: null,
            },
            rules: {
                deviceDtuGroupName: [{ required: true, message: '请输入设备组名称', trigger: 'blur' }],
            },
            registerRules: {
                id: [{ required: true, message: '请输入寄存器地址', trigger: 'blur' }],
            },
            Formopen: false,
            optionsbtl: [
                { label: '300', value: '300' },
                { label: '600', value: '600' },
                { label: '1200', value: '1200' },
                { label: '2400', value: '2400' },
                { label: '4800', value: '4800' },
                { label: '9600', value: '9600' },
                { label: '14400', value: '14400' },
                { label: '19200', value: '19200' },
                { label: '28800', value: '28800' },
                { label: '38400', value: '38400' },
                { label: '56700', value: '56700' },
                { label: '115200', value: '115200' },
                { label: '230400', value: '230400' },
                { label: '460800', value: '460800' },
                { label: '921600', value: '921600' },
            ],
            optionsDir: [
                { label: '禁用', value: '禁用' },
                { label: 'pio0', value: 'pio0' },
                { label: 'pio1', value: 'pio1' },
                { label: 'pio2', value: 'pio2' },
                { label: 'pio3', value: 'pio3' },
                { label: 'pio4', value: 'pio4' },
                { label: 'pio5', value: 'pio5' },
                { label: 'pio6', value: 'pio6' },
                { label: 'pio7', value: 'pio7' },
                { label: 'pio8', value: 'pio8' },
                { label: 'pio9', value: 'pio9' },
                { label: 'pio10', value: 'pio10' },
            ],
        };
    },
    created() {
        this.getList();
    },
    methods: {
        getCspz(tab, avr) {
            this.gatherParams = {
                '485pass': '',
                httpPass: '',
                time: '',
                devices: [],
            };
            this.Pzopen = true;
            this.resettingform();
            this.groupid = avr;
            if (tab !== undefined) {
                const data = JSON.parse(tab);
                this.form = { ...data };
                if (this.form.conf[0].length > 0) {
                    let list = JSON.parse(JSON.stringify(this.form.conf[0]));
                    let num = 0;
                    if (list[0] == 'http') {
                        for (let key in this.confData[0]) {
                            this.confData[0][key] = list[num];
                            num++;
                        }
                    } else if (list[0] == 'socket') {
                        for (let key in this.confData[1]) {
                            this.confData[1][key] = list[num];
                            num++;
                        }
                    } else if (list[0] == 'mqtt') {
                        for (let key in this.confData[2]) {
                            this.confData[2][key] = list[num];
                            num++;
                        }
                    }
                }
                if (this.form.uconf[0][0] !== undefined && this.form.uconf[0][0][0] !== 0) {
                    this.UconfData(0);
                }
                if (this.form.uconf[0][1] !== undefined && this.form.uconf[0][1][0] !== 0) {
                    this.UconfData(1);
                }
                if (this.form.uconf[0][2] !== undefined && this.form.uconf[0][2][0] !== 0) {
                    this.UconfData(2);
                }
                if (this.form['auto485']) {
                    this.gatherStatus = '1';
                    this.gatherParams = {
                        '485pass': this.form['auto485'][0][0],
                        httpPass: this.form['auto485'][0][1],
                        time: this.form['auto485'][0][2],
                        devices: this.form['auto485'][0][3],
                    };
                } else {
                    this.gatherStatus = '0';
                    this.gatherParams = {
                        '485pass': '',
                        httpPass: '',
                        time: '',
                        devices: [],
                    };
                }
            }
        },
        UconfData(i) {
            this.uconfData[i] = {};
            this.uconfData[i].ckcs01 = this.form.uconf[i][0];
            this.uconfData[i].btl01 = this.form.uconf[i][1];
            this.uconfData[i].sjw01 = this.form.uconf[i][2];
            this.uconfData[i].xyw01 = this.form.uconf[i][3];
            this.uconfData[i].tzw01 = this.form.uconf[i][4];
            this.uconfData[i].dir01 = this.form.uconf[i][5];
            this.uconfData[i].zxycsj01 = this.form.uconf[i][6];
        },
        /*切换页面*/
        handleClick(tab) {
            switch (tab) {
                case 'rw':
                    if (this.form.task.length != 0) {
                        this.tasks = [];
                        this.tasks = this.form.task;
                        this.rwsfqy = 0;
                    }
                    break;
            }
        },

        handleClick01(tab, event) {
            console.log(tab, event);
        },
        /*配置确定*/
        getform() {
            if (this.rwsfqy == 0) {
                this.form.task = this.sfdata;
            }
            if (this.uconfData[0].ckcs01 !== 0) {
                this.processUconfData(0);
            }
            if (this.uconfData[1].ckcs01 !== 0) {
                this.processUconfData(1);
            }
            if (this.uconfData[2].ckcs01 !== 0) {
                this.processUconfData(2);
            }
            if (this.form.tdcs01) {
                this.getConfData();
            }
            this.changeData();
            const jsonString = JSON.stringify(this.form);
            const data = {
                devgroupid: this.groupid,
                parameter: jsonString,
            };
            // console.log(data);
            getDevDtu(data).then((re) => {
                this.$modal.msgSuccess(re.msg);
                this.Pzopen = false;
                this.getList();
            });
        },
        processUconfData(uconfDataIndex) {
            if (this.uconfData[uconfDataIndex].ckcs01 == 1) {
                const object = [];
                const data = this.uconfData[uconfDataIndex];
                for (let dataKey in data) {
                    // console.log(data[dataKey]);
                    object.push(data[dataKey]); // 使用push来动态添加元素到数组
                }
                // console.log(object);
                this.form.uconf[uconfDataIndex] = object; // 直接赋值，不需要展开操作符
            }
        },
        getConfData() {
            let index = 0;
            if (this.form.tdlx01 == 'HTTP') {
                index = 0;
            } else if (this.form.tdlx01 == 'SOCKET') {
                index = 1;
            } else if (this.form.tdlx01 == 'MQTT') {
                index = 2;
            }
            let list = [];
            for (let key in this.confData[index]) {
                list.push(this.confData[index][key]);
            }
            this.form.conf[0] = list;
        },
        /*取消*/
        cancel() {
            this.Pzopen = false;
            this.activeName = 'first';
            this.resettingform();
        },
        /*重置表单数据*/
        resettingform() {
            this.form = {
                fota: 0,
                uartReadTime: 25,
                flow: '',
                param_ver: 1,
                pwrmod: 'normal',
                password: '',
                netReadTime: 0,
                passon: 1,
                nolog: '1',
                isRndis: '0',
                isipv6: '0',
                webProtect: '1',
                plate: 0,
                protectContent: [0, 0, 0, 0, 0, 0, 0],
                reg: {
                    type: 0,
                    data: '',
                    prefix: '',
                    postfix: '',
                },
                convert: 0,
                uconf: [[], [], []],
                conf: [[], [], [], [], [], [], []],
                preset: {
                    number: '',
                    delay: '',
                    smsword: '',
                },
                apn: ['', '', ''],
                cmds: [[], [], []],
                pins: [],
                gps: {
                    pio: [],
                    fun: [],
                },
                upprot: ['', '', '', '', '', '', ''],
                dwprot: ['', '', '', '', '', '', ''],
                warn: {
                    adc0: [],
                    adc1: [],
                    vbatt: [],
                    gpio: [],
                },
            };
        },
        /*用户添加*/
        addTask() {
            if (this.tasks.length > 9) {
                this.$modal.msgWarning('用户任务最多10个');
                return;
            }
            let i = this.tasks.length + 1;
            const data = {
                id: i,
                name: '任务' + i,
            };
            this.tasks.push(data);
        },
        /*用户删除*/
        removeTask(taskId) {
            this.tasks = this.tasks.filter((task) => task.id !== taskId);
            const index = this.tasks.length;
            if (index !== -1) {
                this.sfdata.splice(taskId - 1, 1);
                console.log(this.sfdata);
                /*清空*/
                this.tasks = [];
                for (let i = 1; i < index + 1; i++) {
                    const task = {
                        id: i,
                        name: '任务' + i,
                    };
                    this.tasks.push(task);
                }
            }
        },
        getList() {
            const data = {
                Name: this.queryParams.deviceDtuGroupName,
                pageNum: this.queryParams.pageNum,
                pageSize: this.queryParams.pageSize,
            };
            getDtuDeviceGroupList(data).then((rp) => {
                this.tableData = rp.rows;
                this.total = rp.total;
            });
        },
        getQueryCz() {
            this.queryParams.deviceDtuGroupName = null;
            this.queryParams.pageNum = 1;
            this.queryParams.pageSize = 10;
            this.getList();
        },
        getFormopen(tab) {
            if (tab == null) {
                this.title = '添加设备组';
                this.ruleForm = {};
            } else {
                this.title = '修改设备组';
                this.ruleForm = {};
                this.ruleForm = { ...tab };
            }
            this.Formopen = true;
        },
        submitForm(formName) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    addAndUpdateDtuDevGroup(this.ruleForm).then((rp) => {
                        this.$modal.msgSuccess(rp.msg);
                        this.getList();
                    });
                    this.resetForm();
                }
            });
        },
        resetForm(formName) {
            this.Formopen = false;
            this.$refs[formName].resetFields();
        },
        deleteDtuDevGroup(deviceDtuGroupid) {
            deleteDtuDeviceGroup({ deviceDtuGroupid: deviceDtuGroupid }).then((rp) => {
                this.$modal.msgSuccess(rp.msg);
                this.getList();
            });
        },
        addDevice() {
            this.gatherParams.devices.push({
                address: '',
                registers: [],
            });
            this.changeData();
        },
        addRegister() {
            this.$refs['registerform'].validate((valid) => {
                // console.log('valid,', valid);
                if (valid) {
                    let form = JSON.parse(JSON.stringify(this.registerForm));
                    this.gatherParams.devices[this.deviceIndex].registers.push(form);
                    this.registerStatus = false;
                    this.changeData();
                } else {
                    return false;
                }
            });
        },
        registerDelete(e, index) {
            // console.log('e', e);
            this.gatherParams.devices[index].registers.splice(e.$index);
            this.changeData();
        },
        deviceDelete(index) {
            // console.log('e', e);
            this.gatherParams.devices.splice(index, 1);
            this.changeData();
        },
        changeData() {
            if (this.gatherStatus == '1') {
                let list = [];
                for (let key in this.gatherParams) {
                    list.push(this.gatherParams[key]);
                }
                this.form['auto485'] = [list, [], [], [], [], [], []];
            } else {
                this.form['auto485'] = undefined;
            }
        },
    },
};
</script>

<style scoped lang="scss">
.yh_div ul {
    list-style: none;
    display: flex; /* 设置为弹性布局 */
    margin: 0px -3%;
}
.yh_div ul li h3 {
    font-size: 20px;
}
.yh_div ul li button {
    margin: 10px 0px;
}
.btn_sc {
    margin-left: 35%;
}
</style>
